home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug232 / set.st < prev    next >
Text File  |  1987-06-17  |  640b  |  26 lines

  1. Class Set :Collection
  2. | list |
  3. [
  4.         new
  5.                 list <- List new
  6.  
  7. |       add: newElement
  8.         (list includes: newElement)
  9.             ifFalse: [list add: newElement]
  10.  
  11. |       remove: oldElement ifAbsent: exceptionBlock
  12.         list remove: oldElement ifAbsent: exceptionBlock
  13.  
  14. |       size
  15.                 ^ list size
  16.  
  17. |       occurrencesOf: anElement
  18.                 ^ (list includes: anElement) ifTrue: [1] ifFalse: [0]
  19.  
  20. |       first
  21.                 ^ list first
  22.  
  23. |       next
  24.                 ^ list next
  25. ]
  26.